﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace HeadLinx.AD.Explorer
{
    /// <summary>
    /// Replacement for the standard System.Windows.MessageBox.
    /// </summary>
    public partial class MessageBox : Window
    {
        private MessageBoxResult _result = MessageBoxResult.None;

        public MessageBox()
        {
            InitializeComponent();
            this.Title = String.Empty;
        }

        public string Message
        {
            get
            {
                return messageText.Text;
            }
            set
            {
                messageText.Text = value;
            }
        }

        public string Caption
        {
            get
            {
                return this.Title;
            }
            set
            {
                this.Title = value;
            }
        }

        public MessageBoxResult Result
        {
            get
            {
                return _result;
            }
        }

        public static MessageBoxResult Show(string message, string caption)
        {
            MessageBox dlg = new MessageBox();
            dlg.btnCancel.Visibility = Visibility.Collapsed;
            dlg.Message = message;
            dlg.Caption = caption;
            dlg.ShowDialog();
            return dlg.Result;
        }

        public static MessageBoxResult Show(string message)
        {
            MessageBox dlg = new MessageBox();
            dlg.btnCancel.Visibility = Visibility.Collapsed;
            dlg.Message = message;
            dlg.ShowDialog();
            return dlg.Result;
        }

        public static MessageBoxResult Show(string message, string caption, MessageBoxButton buttons, MessageBoxImage image)
        {
            MessageBox dlg = new MessageBox();
            dlg.Message = message;
            dlg.Caption = caption;
            dlg.ShowDialog();
            return dlg.Result;
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            _result = MessageBoxResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            _result = MessageBoxResult.Cancel;
            this.Close();
        }
    }
}
